package com.culturalCenter.dataCenter.mapper.user;

import com.culturalCenter.dataCenter.entity.user.UserDayPoint;
import com.culturalCenter.dataCenter.mapper.base.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserDayPointMapper extends BaseMapper<UserDayPoint> {

    /**
     * 通过用户id查询
     *
     * @param userId 用户id
     *
     * @return
     */
    List<UserDayPoint> queryByUserId(@Param("userId") String userId);

    /**
     * 通过用户id和日期查询
     *
     * @param userId
     * @param date
     *
     * @return
     */
    @Select("SELECT point FROM cdc_user_day_point WHERE userId = #{userId} AND currentDate =#{date} ")
    Integer queryByUserIdAndDate(@Param("userId") String userId, @Param("date") String date);

    /**
     * 通过用户id和日期查询
     *
     * @param userId
     * @param date
     *
     * @return
     */
    @Select("SELECT * FROM cdc_user_day_point WHERE userId = #{userId} AND DATE_FORMAT(currentDate,'%Y-%m') =#{date} ORDER BY currentDate")
    List<UserDayPoint> queryByUserIdAndMonth(@Param("userId") String userId, @Param("date") String date);

}
